<?php
$todayBegin = strtotime(date('Y-m-d',time()).' 00:00:00');
$todayEnd = $todayBegin + 60 * 60 * 24;

$itemData2 = array(
    'city' => 'china.chongqing',
    'bookingStatus' => 'available',
    'startTime' => '>='.$todayBegin,
    'endTime' => '<='.$todayEnd
);
$findText2 = '';
foreach ($itemData2 as $key => $value) {
    $firstChar = substr($value, 0, 1);
    $condition = ($firstChar == '=' || $firstChar == '>'|| $firstChar == '<') ? $key.$value : $key.'='.$value;
    $findText2 = $findText2 == '' ? $condition : $findText2.' '.$condition;
}
$bookingItem = new BWInputValue($bookingId);
$bookingList = new BTreeList($bookingItem);?>
<meta name="viewport" contdent="initial-scale=1, width=device-width, maximum-scale=1, user-scalable=no">
<meta name="viewport" content="initial-scale=1.0,user-scalable=no,maximum-scale=1" media="(device-height: 568px)">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-touch-fullscreen" content="yes">
<meta name="full-screen" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
<style>
.album {
    height: 3.9rem;
    position: relative;
    overflow: hidden;
}

.album img {
    width: 100%;
    min-height: 200px;
    -webkit-transform: translateY(-50%);
    -ms-transform: translateY(-50%);
    -moz-transform: translateY(-50%);
    top: 50%;
    position: relative;
}

.album .desc {
    height: 28px;
    font-size: 14px;
    line-height: 190%;
    position: absolute;
    bottom: 0;
    width: 100%;
    color: white;
    text-align: center;
    background: rgba(0, 0, 0, .5);
}

ul.ul {
padding-left: 20px;
list-style-type: disc;
}

ul.ul li {
    font-size: 14px;
    margin: .1rem 0;
    line-height: 1.6;
}

    /*///*/
#deal-detail .buy-price {
    color: #999;
    position: relative;
}

.buy-price .price {
    vertical-align: text-top;
}

.buy-price strong {
    font-size: .66rem;
}

.buy-price space {
    width: .16rem;
}

.buy-price .buy-btn {
    position: absolute;
    right: .2rem;
    top: .21rem;
    //width: 2.6rem;
}

.buy-desc h1 {
    font-size: 19px;
    margin-top: 5px;
    margin-bottom: 5px;
    color: #000;
    
}

.buy-desc p {
    margin: 0;
    color: #666;
}
.BMapLabel{
    max-width: none;
}
</style>
<body>
    <header class="navbar" style="min-height:52px;margin-bottom:0px;">
        <table style="width:100%;margin-bottom: 0px;">
            <tr>
                <td style="width:10%;text-align:left;">
                    <div style="margin-top:8px;margin-left:10px;"><?php
                        echo $control->getAjaxLink(array(
                            'name' => '<img src="'.Yii::app()->request->baseUrl.'/images/mobile/backbtn.png'.'" />', 
                            'id' => 'manageBooking_remainList'), array(
                            'findText'=>$findText2,
                            'flagText'=>$flagText,
                            'htmlOptions' => array(
                            'enctype' => 'multipart/form-data'
                        )));?> 
                    </div>
                </td>
                <td style="width:80%;text-align:center;"><h4 style="margin-top:15px;"><?php echo $bookingList->getItem('courtDisplayName')->value;?></h4></td>
                <td style="width:10%;text-align:right;"></td>
            </tr>
        </table>
        <div id="ajax-loaderdiv" style="position: fixed;top: 0;left: 0;width: 100%;height: 100%;z-index: 35000;background-color: rgba(0, 0, 0, 0.3);display: none;">
            <img src="/billyn-dev/images/ajax-loader.gif" class="ajax-loader"style="position: absolute;left: 50%;top: 50%;margin-left: -16px;margin-top: -16px;display: block;"/>
        </div>
    </header>
    <div id="deal" class="deal">
    <?php if ($bookingList instanceof BTreeList) { ?>
        <div class="list">
            <div class="album" style="height: 195px;"><?php
                $str = $bookingList->getItem('courtName')->value;
                $bookingStatus = $bookingList->getItem('bookingStatus')->value;
                //$longitude = $bookingList->getItem('longitude')->value;
               // $latitude = $bookingList->getItem('latitude')->value;
                $bookItem = new BWInputValue($bookingId);
                $bookList = new BTreeList($bookItem);
                $addToBookingCartTimeItem = $bookList->getItem('addToBookingCartTime');
                if ($addToBookingCartTimeItem instanceof BTreeItem) {
                    $addToBookingCartTime = $addToBookingCartTimeItem->value;
                    if ($addToBookingCartTime + 15 * 60 > time()) {
                        $bookingStatus = 'unpaid';
                    }
                }
                $str = trim($str);
                if (!empty($str)) {
                    $result = '';
                    for ($i = 0; $i < strlen($str); $i++) {
                        if (is_numeric($str[$i])) {
                            $result.=$str[$i];
                        }
                    }
                }
                $bookdetail = new BWMessage($result);
                $longitudeMedia = $bookdetail->getMediaManager()->getMedia('longitude');
                if($longitudeMedia instanceof BWMedia)
                {
                    $longitude = $longitudeMedia->getContent(); ?>
                    <input id="jing" type="hidden" value="<?php echo $longitude; ?>"/><?php 
                }
                $latitudeMedia = $bookdetail->getMediaManager()->getMedia('latitude');
                if($latitudeMedia instanceof BWMedia)
                {
                    $latitude = $latitudeMedia->getContent(); ?>
                    <input id="wei" type="hidden" value="<?php echo $latitude; ?>"/><?php 
                }
                $courtImageMedia = $bookdetail->getMediaManager()->getMedia('image');
                if ($courtImageMedia instanceof BWMedia) {
                    $courtImage = $bookdetail->getMediaManager()->getMedia('image')->getContent();?>
                    <img src="<?php echo Yii::app()->request->baseUrl . $courtImage; ?>"/><?php 
                } else { ?>
                    <h4>No Picture!</h4><?php 
                }?>
                    <div class="desc"><?php echo $bookingList->getItem('courtDisplayName')->value; ?></div>
        </div>
        <dl class="list list-in">
            <dd class="dd-padding buy-price">
                <div class="price">
                    <strong class="J_pricetag strong-color" style="font-size:30px;"><?php echo $bookingList->getItem('price')->value; ?></strong><span class="strong-color">元</span>
                </div>
            </dd>
            <dd class="dd-padding buy-desc">
                <h1><strong><?php echo $bookingList->getItem('courtDisplayName')->value; ?></strong></h1>
                <ul class="ul" >
                    <li>场地开始时间(0-23):<span style="font-family: inherit;font-weight: bold;padding: 5px;"><?php
                        $startTime = $bookingList->getItem('startTime')->value;
                        echo date('Y-m-d G:i:s', $startTime);?></span>
                    </li>
                    <li>场地结束时间(0-23):<span style="font-family: inherit;font-weight: bold;padding: 5px;"><?php
                        $endTime = $bookingList->getItem('endTime')->value;
                        echo date('Y-m-d G:i:s', $endTime);?></span>
                    </li>
                    <li>详细地址:<span id="address"><span style="font-family: inherit;font-weight: bold;padding: 5px;"><?php 
                        echo $bookingList->getItem('courtAddress')->value; ?></span></span>
                    </li>
                    <li>简介:<span style="font-family: inherit;font-weight: bold;padding: 5px;"> <?php 
                        echo $bookingList->getItem('courtDescription')->value; ?></span>
                    </li>
                    <li style="position: relative;"><span>场馆位置</span>
                        <style type="text/css">
                         #allmap {width:400px;height: 260px;overflow: hidden;margin:0;font-family:"微软雅黑";}
                        </style>
                        <div id="allmap"></div>
                        <script type="text/javascript">
                            //百度地图API功能
                            (function(){ window.BMap_loadScriptTime = (new Date).getTime(); window.BMap=window.BMap||{};window.BMap.apiLoad=function(){delete window.BMap.apiLoad;if(typeof init=="function"){init()}};var s=document.createElement('script');s.src='http://api.map.baidu.com/getscript?v=2.0&ak=258b70c4a5648db1e0a306d017a3c8f6&services=&t=20140930184510';document.body.appendChild(s);})();
                            function init() {
                                x=document.getElementById('jing').value;
                                y=document.getElementById('wei').value;
                                var point = new BMap.Point(x, y);
                                var map = new BMap.Map("allmap");   
                                map.centerAndZoom(point, 15);

                                map.enableScrollWheelZoom();                 //启用滚轮放大缩小
                                var top_left_control = new BMap.ScaleControl({anchor: BMAP_ANCHOR_TOP_LEFT});// 左上角，添加比例尺
                                var top_left_navigation = new BMap.NavigationControl();  //左上角，添加默认缩放平移控件
                                var top_right_navigation = new BMap.NavigationControl({anchor: BMAP_ANCHOR_TOP_RIGHT, type: BMAP_NAVIGATION_CONTROL_SMALL}); //右上角，仅包含平移和缩放按钮
                                map.addControl(top_left_control);        
                                map.addControl(top_left_navigation);     
                                map.addControl(top_right_navigation);   

                                var address= document.getElementById("address").innerHTML;
                                var marker = new BMap.Marker(point);  
                                map.addOverlay(marker);       
                                marker.setAnimation(BMAP_ANIMATION_BOUNCE); //跳动的动画
                                var label = new BMap.Label(address,{offset:new BMap.Size(15,-30)});
                                marker.setLabel(label);
                            }
                        </script>
                    </li>
                </ul>
            </dd>
        </dl>
        </div>
    <?php }?>
    </div>
    <footer>
        <div class="footer-copyright">
            <div class="hr"></div>
            <span class="footer-copyright-text">
                Copyright © 2014 billyn.net </span>
        </div>
    </footer>
</body>